// Loesung_von_Aufgabe_7.6_3_Balmer

// Die vier sichtbaren Linien des Wasserstoffs
// Photonen werden emittiert

PImage Bild;
float x1 = 480;
float y1 = 228;
float x2 = 510;
float y2 = 228;
float x3 = 530;
float y3 = 228;
float x4 = 560;
float y4 = 228;

void setup() 
{
  size(900, 600);
}

void draw()
{
  background(220);

  // Bild des Wasserstoffspektrums wird eingefügt
  Bild = loadImage("HS_0001.jpg");
  imageMode(CENTER);
  image(Bild, 450, 500);

  // Atomkern und Elektronenbahnen werden gezeichnet
  noStroke();
  fill(255, 0, 0);
  ellipse(450, 230, 3, 3);

  stroke(0);
  strokeWeight(2);
  noFill();
  ellipse(450, 230, 10.6, 10.6);
  ellipse(450, 230, 42.4, 42.4);
  ellipse(450, 230, 95.2, 95.2);
  ellipse(450, 230, 169.7, 169.7);
  ellipse(450, 230, 264.6, 264.6);
  ellipse(450, 230, 381.0, 381.0);

  // Elektronensprünge und Photonen werden gezeichnet
  if (mouseX >= 600 && mouseX <= 604 && mouseY >= 450 && mouseY <= 520)
  {
    stroke(255);
    strokeWeight(15);
    point(450+47.6, 230);
    strokeWeight(3);
    line(450+47.6, 230, 450+21.2, 230);
    fill(255);
    triangle(450+23, 230, 450+36, 225, 450+36, 235);

    x1++;
    y1--;
    noStroke();
    fill(#FC0303);
    ellipse(x1, y1, 10, 10);
  }
  if (mouseX < 600 || mouseX > 604 || mouseY < 450 || mouseY > 520)
  {
    x1 = 480;
    y1 = 228;
  }

  if (mouseX > 259 && mouseX < 263 && mouseY > 450 && mouseY < 520)
  {
    stroke(255);
    strokeWeight(15);
    point(450+84.7, 230);
    strokeWeight(3);
    line(450+84.7, 230, 450+21.2, 230);
    fill(255);
    triangle(450+23, 230, 450+36, 225, 450+36, 235);

    x2++;
    y2--;
    noStroke();
    fill(#03E5FC);
    ellipse(x2, y2, 10, 10);
  }

  if (mouseX < 259 || mouseX > 263 || mouseY < 450 || mouseY > 520)
  {
    x2 = 510;
    y2 = 228;
  }

  if (mouseX >= 156 && mouseX <= 160 && mouseY >= 450 && mouseY <= 520)
  {
    stroke(255);
    strokeWeight(15);
    point(450+132.3, 230);
    strokeWeight(3);
    line(450+132.6, 230, 450+21.2, 230);
    fill(255);
    triangle(450+23, 230, 450+36, 225, 450+36, 235);

    x3++;
    y3--;
    noStroke();
    fill(#2708FA);
    ellipse(x3, y3, 10, 10);
  }

  if (mouseX < 156 || mouseX > 160 || mouseY < 450 || mouseY > 520)
  {
    x3 = 530;
    y3 = 228;
  }

  if (mouseX >= 107 && mouseX <= 111 && mouseY >= 450 && mouseY <= 520)
  {
    stroke(255);
    strokeWeight(15);
    point(450+190.5, 230);
    strokeWeight(3);
    line(450+190.5, 230, 450+21.2, 230);
    fill(255);
    triangle(450+23, 230, 450+36, 225, 450+36, 235);

    x4++;
    y4--;
    noStroke();
    fill(#6C0BDE);
    ellipse(x4, y4, 10, 10);
  }

  if (mouseX < 107 || mouseX > 111 || mouseY < 450 || mouseY > 520)
  {
    x4 = 560;
    y4 = 228;
  }
}